//
//  AddressModel.swift
//  ShareUmbrella
//
//  Created by keng fu on 2017/9/17.
//  Copyright © 2017年 尧尚信息科技. All rights reserved.
//

import UIKit

class AddressModel: NSObject, NSCoding {
    func encode(with aCoder: NSCoder) {
        aCoder.encode(uid,forKey:"uid")
        aCoder.encode(name,forKey:"name")
        aCoder.encode(adcode,forKey:"adcode")
        aCoder.encode(district,forKey:"district")
        aCoder.encode(address,forKey:"address")
        aCoder.encode(latitude,forKey:"latitude")
        aCoder.encode(longitude,forKey:"longitude")
    }

    
    var uid : String = ""
    
    var name : String = ""

    var adcode : String = ""
    
    var district : String = ""

    var address : String = ""
    
    var latitude : Double = 0.0
    
    var longitude : Double = 0.0
    
    //构造方法
    init(uid:String="",name:String="",adcode:String="",district:String="",address:String="",latitude:Double=0.0,longitude:Double=0.0){
        self.uid = uid
        self.name = name
        self.adcode = adcode
        self.district = district
        self.address = address
        self.latitude = latitude
        self.longitude = longitude
        
        super.init()
    }
    
    //从nsobject解析回来
    required init(coder aDecoder:NSCoder){
        self.uid=aDecoder.decodeObject(forKey: "uid") as! String
        self.name=aDecoder.decodeObject(forKey: "name") as! String
        self.adcode=aDecoder.decodeObject(forKey: "adcode") as! String
        self.district=aDecoder.decodeObject(forKey: "district") as! String
        self.address=aDecoder.decodeObject(forKey: "address") as! String
        self.latitude=aDecoder.decodeObject(forKey: "latitude") as! Double
        self.longitude=aDecoder.decodeObject(forKey: "longitude") as! Double
    }

}
